package com.hz.zbl.mapper;

import com.hz.zbl.model.entity.ClassEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ClassMapper {

    @Select("SELECT * FROM classes")
    List<ClassEntity> selectAllClasses();

    @Select("SELECT * FROM classes WHERE id = #{id}")
    ClassEntity selectClassById(@Param("id") int id);

    @Select("SELECT * FROM classes WHERE grade_id = #{grade_id}")
    ClassEntity selectClassByGid(@Param("grade_id") int grade_id);

    @Select("SELECT * FROM classes WHERE class_name = #{class_name}")
    ClassEntity selectClassByName(@Param("class_name") String class_name);

    @Delete("DELETE FROM classes WHERE id = #{id}")
    int deleteClassById(@Param("id") int id);

    @Insert("INSERT INTO classes VALUES (null, #{class_name}, #{grade_id}, #{grade_name}, #{grade_year})")
    int addClass(ClassEntity classEntity);
}
